/**
 * Command Line Interpreter to ask questions
 * and receive answers.
 * 
 * @author Chris Baillie
 */

package app;

import java.io.*;

public class CLI {
	
	BufferedReader br;
	
	public CLI()
	{
		br = new BufferedReader(new InputStreamReader(System.in));
	}
	
	public int getInt(String question)
	{
		System.out.println(question);
		try{
			return Integer.parseInt(br.readLine());
		}catch(NumberFormatException e){
			System.out.println("Please enter a string!");
			return getInt(question);
		}catch(Exception e){
			System.out.println("Please enter a value.");
			return getInt(question);
		}
	}
	
	public String getString(String question)
	{
		System.out.println(question);
		try{
			String res = br.readLine();
			if(res.equals("")){
				System.out.println("Please enter a value.");
				return getString(question);
			}
			return res;
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}
}
